package cn.offcn.controller;

import cn.offcn.entity.Role;
import cn.offcn.service.RoleService;
import cn.offcn.utils.OAResult;
import cn.offcn.utils.TableVo;
import org.apache.taglibs.standard.lang.jstl.NullLiteral;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @author yuliantao
 * @create 2020 -09 -2020-09-18 16:35
 * @description 功能描述
 */
@Controller
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService ;


    @RequestMapping("/addRole")
    @ResponseBody
    public OAResult addRole(Role role,String sourcesIds){
        return roleService.addRole(role,sourcesIds);
    }


    @ResponseBody
    @RequestMapping("/getAllRoles")
    private TableVo<Role> getAllRoles(int page, int limit) {

        return roleService.getAllRolers(page, limit);
    }

    @RequestMapping("/deleteRoleByRoleid")
    @ResponseBody
    public OAResult deleteRoleByRoleid(int roleid){
        return roleService.deleteRoleByRoleid(roleid);
    }


    @RequestMapping("/getRoleByRoleid")
    @ResponseBody
    public Map getRoleByRoleid(int roleid){
        return roleService.getRoleByRoleid(roleid) ;

    }
    @RequestMapping("/updateRole")
    @ResponseBody
    public OAResult updateRole(Role role,String sourcesIds){
        return roleService.updateRole( role,sourcesIds) ;

    }


}
